package com.yuyou.tas.admin;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import com.yuyou.tas.admin.service.IAuthOrganService;
import com.yuyou.tas.service.api.admin.entity.AuthOrganization;
import com.yuyou.tas.util.bean.EncryptVO;
import com.yuyou.tas.util.constant.out.CommConst;

@Component
@Order(value=1)
public class StartupRunner implements CommandLineRunner{

	
	@Autowired
	private IAuthOrganService authOrganService;
	
	@Autowired
	private StringRedisTemplate stringRedisTemplate;
	
	

	
	@Override
	public void run(String... arg0) throws Exception {
		System.out.println(">>>>>>>>>>>>>>>服务启动执行，执行加载数据等操作<<<<<<<<<<<<<");	
		List<AuthOrganization> list=authOrganService.selectAll();		
		list.stream().forEach(organ -> {				
			EncryptVO vo=new EncryptVO(organ.getSysCode(),organ.getEncrypt(),organ.getId());
			stringRedisTemplate.opsForValue().set(CommConst.pre+organ.getSysCode(), vo.toJson());
		});
		
		
	}

}
